package com.hzlj.position.config.common.enums;

import com.fz.common.base.exception.PubError;
import com.fz.common.base.exception.PubException;
import lombok.Getter;

/**
 * @author fanzhuo
 */

@Getter
public enum Channel {
    APP("1", "APP定位"),
    MOBILE("2", "手机定位-移动"),
    TELECOM("3", "手机定位-电信"),
    UNICOM("4", "手机定位-联通"),
    WD("5", "腕带定位"),
    ;

    private String code;
    private String text;

    Channel(String code, String text) {
        this.code = code;
        this.text = text;
    }

    public static Channel of(String value) {
        for (Channel reportType : values()) {
            if (reportType.getCode().equals(value)) {
                return reportType;
            }
        }
        throw new PubException(PubError.PARAM_EMPTY_ERROR);
    }

    public static Channel ofName(String name) {
        for (Channel reportType : values()) {
            if (reportType.name().equalsIgnoreCase(name)) {
                return reportType;
            }
        }
        throw new PubException(PubError.PARAM_EMPTY_ERROR);
    }
}
